package com.vieewer.btdemo.utils

import android.content.Context
import android.os.Environment
import android.os.StatFs
import android.util.Log
import android.content.Context.WIFI_SERVICE
import android.net.wifi.WifiManager
import android.bluetooth.BluetoothAdapter


class SugonInfoUtils {

    companion object {

        //读取系统内部空间
        fun getDiskValue() : String{

            val root = Environment.getRootDirectory()
            val sf = StatFs(root.path)
            val blockSize = sf.blockSize
            val availCount = sf.availableBlocks
            val blockCount = sf.blockCount.toLong()
            var diskValue = (availCount * blockSize / 1024 / 1024).toString() + "MB"
            var totalValue = (blockSize * blockCount / 1024 / 1024).toString() + "MB"
            Log.i("yjj", "SugonInfoUtils diskValue =$diskValue,totalValue = $totalValue")
            return diskValue

        }


        //读取系统内部空间
        fun getDiskTotal() : String{

            val root = Environment.getRootDirectory()
            val sf = StatFs(root.path)
            val blockSize = sf.blockSize
            val availCount = sf.availableBlocks
            val blockCount = sf.blockCount.toLong()
            var diskValue = (availCount * blockSize / 1024 / 1024).toString() + "MB"
            var totalValue = (blockSize * blockCount / 1024 / 1024).toString() + "MB"
            Log.i("yjj", "SugonInfoUtils diskValue =$diskValue,totalValue = $totalValue")
            return totalValue

        }




        fun getConnectWifiSsid(ctx : Context): String {

            val wifiManager = ctx.getSystemService(WIFI_SERVICE) as WifiManager?
            val wifiInfo = wifiManager!!.connectionInfo
            Log.d("wifiInfo", wifiInfo.toString())
            Log.d("SSID", wifiInfo.ssid)
            return wifiInfo.ssid

        }


        fun getBluetoothName() : String{

            val bluetoothAdapter = BluetoothAdapter.getDefaultAdapter()
            //判断蓝牙功能是否存在
            if (bluetoothAdapter == null) {
                Log.i("yjj","该设备不支持蓝牙")
                return ""
            }
            //获取名字 MAC地址
            var name = bluetoothAdapter.name
            var address = bluetoothAdapter.address
            Log.i("yjj", "蓝牙名: " + name+ "mac地址:" + address)

            return name

        }




    }



}